package com.sskj.wallet.ui.activity;


import android.widget.Button;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.sskj.common.base.App;
import com.sskj.common.util.ClickUtil;
import com.sskj.lib.Constans;
import com.sskj.lib.RConfig;
import com.sskj.lib.base.BaseActivity;
import com.sskj.wallet.R;
import com.sskj.wallet.R2;
import com.sskj.wallet.presenter.BackupTipActivityPresenter;
import com.sskj.wallet.uitl.TipWalletUtil;

import butterknife.BindView;

@Route(path = RConfig.WALLET_BACKUP_TIP)//备份提示
public class BackupTipActivity extends BaseActivity<BackupTipActivityPresenter> {
    @Autowired
    boolean isPrivate;
    @Autowired
    boolean isKeyStore=false;
    @Autowired
    String code;
    @BindView(R2.id.tvDesc)
    TextView tvDesc;
    @BindView(R2.id.tvDesc1)
    TextView tvDesc1;
    @BindView(R2.id.tvDesc2)
    TextView tvDesc2;
    @BindView(R2.id.btSubmit)
    Button btSubmit;

    @Override
    protected int getLayoutId() {
        return R.layout.wallet_activity_backup_tip;
    }

    @Override
    public BackupTipActivityPresenter getPresenter() {
        return new BackupTipActivityPresenter();
    }

    @Override
    protected void initView() {
        ARouter.getInstance().inject(this);
        if (isKeyStore){
            tvDesc1.setText(App.INSTANCE.getString(R.string.wallet_backupTipActivity1_j));
            tvDesc2.setText(App.INSTANCE.getString(R.string.wallet_backupTipActivity2_j));
            tvDesc.setText(App.INSTANCE.getString(R.string.wallet_backupTipActivity3_j));
        }else {
            if (!isPrivate) {
                tvDesc1.setText(App.INSTANCE.getString(R.string.wallet_backupTipActivity4_j));
                tvDesc2.setText(App.INSTANCE.getString(R.string.wallet_backupTipActivity5_j));
                tvDesc.setText(App.INSTANCE.getString(R.string.wallet_backupTipActivity6_j));
            }
        }
        ClickUtil.click(btSubmit, () -> {
            TipWalletUtil.showNoCameraTip(this, () -> {
                if (isKeyStore){
                    ARouter.getInstance().build(RConfig.WALLET_BACKUP_KEYSTORE)
                            .withBoolean(Constans.IS_PRIVATE, false)
                            .withString(Constans.CODE, code)
                            .navigation();
                }else {
                    if (isPrivate) {
                        ARouter.getInstance().build(RConfig.WALLET_BACKUP_KEYSTORE).withBoolean(Constans.IS_PRIVATE, true).withString(Constans.CODE, code).navigation();
                    } else {
                        ARouter.getInstance().build(RConfig.WALLET_BACKUP_WORD).withString(Constans.CODE, code).navigation();
                    }
                }
                finish();
            });
        });
    }


}
